package com.baosight.sczx.common.zm.cInterface.cc;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.iplat4j.util.NumberUtils;
import com.baosight.iplat4j.util.StringUtils;

public class _5ExamineItem {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	/**
	 * 获得所有五个到位考核项目
	 * <p>Function: getQualitystandardItems</p>
	 * <p>Description: </p>
	 * <p>return value:List</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-6-29上午09:22:24 严洪浩
	 * </p>
	 *
	 */
	@SuppressWarnings("rawtypes")
	public static List get5examineItems() {
		List  _list = new ArrayList();
		_list = dao.query("ZMCC5examineItems.queryAll", null);;
		return _list;
	}
	
	/**
	 * 获取总分
	 * <p>Function: getSumPoint</p>
	 * <p>Description: </p>
	 * <p>return value:float</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-6-30上午05:24:40 严洪浩
	 * </p>
	 *
	 */
	@SuppressWarnings("rawtypes")
	public static float getSumPoint(String fdOrgId) {
		List  _list = new ArrayList();
		Map<String, String> _argsMap = new HashMap<String, String>();
		_argsMap.put("fdOrgId", fdOrgId);
		
		_list = dao.query("ZMCC5examineItems.queryPointValue", _argsMap);;
		
		float result = 0;
		for(int i = 0; i < _list.size(); i++) {
			Map _map = (Map)_list.get(i);
			float fdItemPoint = NumberUtils.toFloat(StringUtils.toString(_map.get("fdItemPoint")));//项目分数
			float fdRate = NumberUtils.toFloat(StringUtils.toString(_map.get("fdRate")));//权重比
			result += fdItemPoint * fdRate;
		}
		
		//四舍五入  保留一位小数
		BigDecimal temp = new BigDecimal(result);
		float _value = temp.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue();
		return _value;
	}
}
